import 'package:flutter/cupertino.dart';
import 'package:city_corner/commons/cell.dart';
import 'package:flutter/material.dart';
import 'package:flutter_my_picker/common/date.dart';
import 'package:flutter_my_picker/flutter_my_picker.dart';

class TimeItem extends StatefulWidget {
  @override
  State<StatefulWidget> createState() {
    return _TimeItem();
  }
}

class _TimeItem extends State<TimeItem> {
  @override
  Widget build(BuildContext context) {
    DateTime date;
    String dateStr;
    String value = '';

    _change(formatString) {
      return (_date) {
        setState(() {
          date = _date;
          dateStr = MyDate.format(formatString, _date);
        });
      };
    }

    return Cell(
      label: '看房时间',
      value: value,
      onTap: () {
        MyPicker.showDateTimePicker(
          context: context,
          background: Colors.white,
          color: Colors.black,
          current: date,
          magnification: 1.2,
          squeeze: 1.45,
          offAxisFraction: 0.2,
          onChange: _change('yyyy-MM-dd HH:mm'),
        );
      },
    );
  }
}
